#include<stdio.h>
#include<getopt.h>
#include "netdrive.h"

extern struct interface am_interface;
extern struct interface drive_interface;
struct node *bknode,*tmpbknode;
void usage();

char* const short_options="a:e:m:o";
struct option long_options[]={
	{"name",1,NULL,'a'};
	{"login",0,NULL,'e'};
	{"create",0,NULL,'m'};
	{"upload",0,NULL,'0'};
	{0,0,0,0};
};

int main(int argc, char **argv)
{
	int ch,code;
	char name[128];
	dive_interface=&am_interface;
	while((ch=getopt_long(argc,argv,short_options,long_options,NULL)) != -1)
	{
		switch(ch){
			case 'a':
				strncpy(name,optarg,128);
				printf("get name:%s",name);
				break;
			case 'e':
				code=drive_interface->login();
				break;
			case 'm':
				code=drive_interface->create_folder();
				break;
			case 'o':
				code=drive_interface->upload_file();
				break;
			default:
				printf("please input at least one option\n");
				usage();
				exit(EXIT_FAILURES);

				
		}
	}
	return 0;
}

void usage()
{
	int i=0;
	printf("Usage:i\n");
	for(i=0;long_options[i].val !=0;i++)
		printf("-%c  --%s\n",long_options[i].val,long_options[i].name);
}
